package cn.zyq.ykb.service.sys;


import cn.zyq.ykb.beans.sys.SysAdmin;
import cn.zyq.ykb.beans.sys.SysJob;
import cn.zyq.ykb.system.common.PageParam;
import cn.zyq.ykb.system.ry.quartz.TaskException;
import com.github.pagehelper.PageInfo;
import org.quartz.SchedulerException;

import java.util.List;

public interface SysJobService {
    PageInfo<SysJob> list(PageParam pageParam);

    void add(SysJob param, SysAdmin admin) throws SchedulerException, TaskException;

    void update(SysJob param, SysAdmin admin) throws SchedulerException, TaskException;

    void del(String serviceID, SysAdmin admin);

    SysJob detail(String serviceID, SysAdmin admin);

    SysJob detail(String serviceID);

    List<SysJob> selectJobList(SysJob sysJob);

    SysJob selectJobById(Integer jobId);

    /**
     * 任务调度状态修改
     *
     * @param job 调度信息
     * @return 结果
     */
    public int changeStatus(SysJob job) throws SchedulerException;

    /**
     * 恢复任务
     *
     * @param job 调度信息
     * @return 结果
     */
    public int resumeJob(SysJob job) throws SchedulerException;

    /**
     * 暂停任务
     *
     * @param job 调度信息
     * @return 结果
     */
    public int pauseJob(SysJob job) throws SchedulerException;
    /**
     * 立即运行任务
     *
     * @param job 调度信息
     * @return 结果
     */
    public boolean run(SysJob job) throws SchedulerException;


    /**
     * 批量删除调度信息
     *
     * @param jobIds 需要删除的任务ID
     * @return 结果
     */
    public void deleteJobByIds(Integer[] jobIds) throws SchedulerException;

    /**
     * 删除任务后，所对应的trigger也将被删除
     *
     * @param job 调度信息
     * @return 结果
     */
    public int deleteJob(SysJob job) throws SchedulerException;

}
